﻿/***************************
 * H E A L T H   R U L E S *
 ***************************/

/* BMI: Chỉ số cơ thể */
rule(
	'HEALTHR01',
	lhs([av(height, H), av(weight, W), BMI is W*10000/(H*H)]),
	rhs(av(bmi, BMI), 1)
).
rule(
	'HEALTHR02',
	lhs([av(bmi, BMI), av(gender, male), BMI < 20]),
	rhs(av(fitness, thin), 0.45)
).
rule(
	'HEALTHR03',
	lhs([av(bmi, BMI), av(gender, male), BMI >= 20, BMI < 25]),
	rhs(av(fitness, normal), 0.45)
).
rule(
	'HEALTHR04',
	lhs([av(bmi, BMI), av(gender, male), BMI >= 25, BMI < 30]),
	rhs(av(fitness, fat), 0.45)
).
rule(
	'HEALTHR05',
	lhs([av(bmi, BMI), av(gender, male), BMI > 30]),
	rhs(av(fitness, over_weighted), 0.45)
).
rule(
	'HEALTHR06',
	lhs([av(bmi, BMI), av(gender, female), BMI < 18]),
	rhs(av(fitness, thin), 0.45)
).
rule(
	'HEALTHR07',
	lhs([av(bmi, BMI), av(gender, female), BMI >= 18, BMI < 23]),
	rhs(av(fitness, normal), 0.45)
).
rule(
	'HEALTHR08',
	lhs([av(bmi, BMI), av(gender, female), BMI >= 23, BMI < 30]),
	rhs(av(fitness, fat), 0.45)
).
rule(
	'HEALTHR09',
	lhs([av(bmi, BMI), av(gender, female), BMI > 30]),
	rhs(av(fitness, over_weighted), 0.45)
).

/* Chế độ ăn cho người gầy:
	- Nhiều béo
	- Nhiều đường
	- Nhiều vitamin và khoáng
*/
rule(
	'HEALTHR10a',
	lhs([av(fitness, thin), av(glucose(X), high)]),
	rhs(av(like_recipe(X), true), 0.45)
).
rule(
	'HEALTHR10b',
	lhs([av(fitness, thin), av(fat(X), high)]),
	rhs(av(like_recipe(X), true), 0.45)
).
rule(
	'HEALTHR10c',
	lhs([av(fitness, thin), av(vitamins(X), high)]),
	rhs(av(like_recipe(X), true), 0.35)
).
rule(
	'HEALTHR10d',
	lhs([av(fitness, thin), av(minerals(X), high)]),
	rhs(av(like_recipe(X), true), 0.35)
).
/* Chế độ ăn cho người béo:
	- Ít béo
	- Trung bình dinh dưỡng
	- Nhiều vitamin và khoáng
*/
rule(
	'HEALTHR11b',
	lhs([av(fitness, fat), av(fat(X), low)]),
	rhs(av(like_recipe(X), true), 0.45)
).
rule(
	'HEALTHR11b',
	lhs([av(fitness, fat), av(fat(X), high)]),
	rhs(av(like_recipe(X), true), -0.5)
). 
rule(
	'HEALTHR11c',
	lhs([av(fitness, fat), av(vitamins(X), high)]),
	rhs(av(like_recipe(X), true), 0.35)
).
rule(
	'HEALTHR11d',
	lhs([av(fitness, fat), av(minerals(X), high)]),
	rhs(av(like_recipe(X), true), 0.35)
).

/* Chế độ ăn cho người quá tải:
	- Ít béo
	- Ít dinh dưỡng
	- Nhiều vitamin và khoáng
*/
rule(
	'HEALTHR11b',
	lhs([av(fitness, over_weighted), av(fat(X), low)]),
	rhs(av(like_recipe(X), true), 0.45)
).
rule(
	'HEALTHR11b',
	lhs([av(fitness, over_weighted), av(fat(X), high)]),
	rhs(av(like_recipe(X), true), -0.9)
). 

rule(
	'HEALTHR11c',
	lhs([av(fitness, over_weighted), av(vitamins(X), high)]),
	rhs(av(like_recipe(X), true), 0.45)
).
rule(
	'HEALTHR11d',
	lhs([av(fitness, over_weighted), av(minerals(X), high)]),
	rhs(av(like_recipe(X), true), 0.45)
).

/* Dị ứng */

rule(
	'ALLERGY01',
	lhs([av(allergy, LofAllergy), member(Ingredient, LofAllergy), log('allgery'), 
		av(ingredients(Recipe), LofIngredient), member(Ingredient, LofIngredient)]),
	rhs(av(like_recipe(Recipe), true), -0.9999)
).

/* Disease Facts */
disease(flu). % an chao hanh tia to, an pho, an bun
disease(toothache). % an do mem
disease(acne). % an do mat, nhieu Vitamin, tranh do nong, cay
disease(stomachache). % tranh do nong, cay
disease(diabetes). %  an it duong, an nhieu protein, rau
disease(gout). % tranh protein
disease(osteoporosis). % an nhieu khoang, rau
disease(heart_disease). % tranh do an beo
disease(high_cholesteron). % tranh do an beo

fact(av(term(flu), short), 1).
fact(av(term(toothache), short), 1).
fact(av(term(acne), short), 1).
fact(av(term(stomachache), long), 1).
fact(av(term(diabetes), long), 1).
fact(av(term(gout), long), 1).
fact(av(term(osteoporosis), long), 1).
fact(av(term(heart_disease), long), 1).
fact(av(term(high_cholesteron), long), 1).


/*** Bệnh ngắn hạn*/

/*** Bệnh mãn tính*/


/*
rule(
	'DISEASE01',
	lhs([av(isDisease, no)]),
	rhs(av(disease, []), 1)
).
*/

/* Chế độ ăn cho người cảm */
rule(
	'DISEASE02a',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(flu, LofDisease), av(hardness(X), tender)]),
	rhs(av(like_recipe(X), true), 0.4)
).
rule(
	'DISEASE02b',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(flu, LofDisease), av(glucose(X), high)]),
	rhs(av(like_recipe(X), true), 0.4)
).
rule(
	'DISEASE02c',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(flu, LofDisease), av(vitamins(X), high)]),
	rhs(av(like_recipe(X), true), 0.4)
).
rule(
	'DISEASE02d',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(flu, LofDisease), av(minerals(X), high)]),
	rhs(av(like_recipe(X), true), 0.4)
).

/* Chế độ ăn cho người đau răng */
rule(
	'DISEASE03a',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(toothache, LofDisease), av(hardness(X), tender)]),
	rhs(av(like_recipe(X), true), 0.4)
).

/* Chế độ ăn cho người bị mụn */
rule(
	'DISEASE04a',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(acne, LofDisease), av(hotcold(X), hot)]),
	rhs(av(like_recipe(X), true), -0.3)
).
rule(
	'DISEASE04b',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(acne, LofDisease), av(fat(X), high)]),
	rhs(av(like_recipe(X), true), -0.3)
).
rule(
	'DISEASE04c',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(acne, LofDisease), av(vitamins(X), high)]),
	rhs(av(like_recipe(X), true), 0.4)
).

/* Chế độ ăn cho người đau dạ dày */
rule(
	'DISEASE05a',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(stomachache, LofDisease), av(taste(X), sour)]),
	rhs(av(like_recipe(X), true), -0.6)
).
rule(
	'DISEASE05b',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(stomachache, LofDisease), av(taste(X), hot)]),
	rhs(av(like_recipe(X), true), -0.6)
).

/* Chế độ ăn cho người tiểu đường */
rule(
	'DISEASE06a',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(diabetes, LofDisease), av(taste(X), sweet)]),
	rhs(av(like_recipe(X), true), -0.8)
).
rule(
	'DISEASE06b',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(diabetes, LofDisease), av(glucose(X), high)]),
	rhs(av(like_recipe(X), true), -0.8)
).
rule(
	'DISEASE06c',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(diabetes, LofDisease), av(glucose(X), low)]),
	rhs(av(like_recipe(X), true), 0.4)
).
rule(
	'DISEASE06d',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(diabetes, LofDisease), av(protein(X), high)]),
	rhs(av(like_recipe(X), true), 0.4)
).

/* Chế độ ăn cho người gout */

rule(
	'DISEASE07b',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(gout, LofDisease), av(protein(X), high)]),
	rhs(av(like_recipe(X), true), -0.8)
).
rule(
	'DISEASE07c',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(gout, LofDisease), av(protein(X), low)]),
	rhs(av(like_recipe(X), true), 0.4)
).

/* Chế độ ăn cho người loãng xương */
rule(
	'DISEASE07b',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(osteoporosis, LofDisease), av(minerals(X), high)]),
	rhs(av(like_recipe(X), true), 0.4)
).
rule(
	'DISEASE07c',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(osteoporosis, LofDisease), av(vitamins(X), high)]),
	rhs(av(like_recipe(X), true), 0.4)
).

/* Chế độ ăn cho người tim mạch */
rule(
	'DISEASE08a',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(heart_disease, LofDisease), av(calorie(X), high)]),
	rhs(av(like_recipe(X), true), -0.9)
).
rule(
	'DISEASE08a',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(heart_disease, LofDisease), av(fat(X), high)]),
	rhs(av(like_recipe(X), true), -0.9)
).
rule(
	'DISEASE08a',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(heart_disease, LofDisease), av(fat(X), low)]),
	rhs(av(like_recipe(X), true), 0.4)
).

/* Chế độ ăn cho người bệnh máu nhiễm mỡ */
rule(
	'DISEASE09a',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(high_cholesteron, LofDisease), av(calorie(X), high)]),
	rhs(av(like_recipe(X), true), -0.9)
).
rule(
	'DISEASE09a',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(high_cholesteron, LofDisease), av(fat(X), high)]),
	rhs(av(like_recipe(X), true), -0.9)
).
rule(
	'DISEASE09a',
	lhs([av(isDisease, yes), av(disease, LofDisease), member(high_cholesteron, LofDisease), av(fat(X), low)]),
	rhs(av(like_recipe(X), true), 0.4)
).